package com.lfg.leetcode.leetcode0;

public class ListNode {
    public int val;
    public ListNode next;

    ListNode(int x) {
        val = x;
    }

    public static ListNode deserialize(String data) {
        if ("".equals(data) || null == data) {
            return null;
        }
        data = data.substring(1, data.length() - 1);
        String[] datas = data.split(",");
        ListNode header = null;
        ListNode ret = null;
        for (String s : datas) {
            if (null == s || "".equals(s)) {
                continue;
            }
            ListNode node = new ListNode(Integer.valueOf(s));
            if (null == header) {
                header = node;
                ret = node;
            } else {
                header.next = node;
                header = node;
            }
        }
        return ret;
    }
}